#!/usr/bin/env python
from OpenGL.GL import *
from Vector import *
from Color import *
from GLWrappers import *

DefaultPosition = Vector()
DefaultAmbience = Color(1.0)
DefaultDiffuse = Color(0.0)
DefaultSpecular = Color(0.0)

class Light(Vector):
    def __init__(self, x, y, z, ID=GL_LIGHT0, On=True, a=DefaultAmbience, d=DefaultDiffuse, s=DefaultSpecular):
        Vector.__init__(self, x, y, z)
        self.ID = ID
        self.a = a
        self.d = d
        self.s = s

        self.On = On
        if self.On:
            glEnable(self.ID)
        else:
            glDisable(self.ID)

    def Toggle():
        self.On = not self.On
        if self.On:
            glEnable(self.ID)
        else:
            glDisable(self.ID)

    def Draw(self):
        glLight(self.ID, GL_AMBIENT, self.a)
        glLight(self.ID, GL_DIFFUSE, self.d)
        glLight(self.ID, GL_SPECULAR, self.s)
        glLight(self.ID, GL_POSITION, self)

Lights = list()

Lights.append(Light(-5.0, 8.0, -5.0, a=DefaultAmbience, d=DefaultDiffuse, s=DefaultSpecular))